<?php
date_default_timezone_set('Asia/Jakarta');
$rootPath = dirname(dirname(__FILE__));
set_include_path(get_include_path() . PATH_SEPARATOR .  
                 $rootPath . '/application' . PATH_SEPARATOR .  
                 $rootPath . '/library' . PATH_SEPARATOR .  
                 $rootPath . '/html');

require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();

$config = new Zend_Config_Ini('../application/config.ini', 'general');

$registry = Zend_Registry::getInstance();
$registry->set('config', $config);

$db = Zend_Db::factory($config->db);
Zend_Db_Table::setDefaultAdapter($db);

$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory('../application/default/controllers', 'default');
$controller->addControllerDirectory('../application/authentication/controllers', 'authentication');
$controller->addControllerDirectory('../application/thamdinh/controllers', 'thamdinh');
$controller->addControllerDirectory('../application/tracuu/controllers', 'tracuu');
$controller->addControllerDirectory('../application/danhmuc/controllers', 'danhmuc');
require_once 'Zend/Layout.php'; 
$layout = Zend_Layout::startMvc($config->appearance);
//$layout->getView()->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');

//require_once 'Common/button.php';
require_once 'Common/tvtkcommon.php';
//require_once 'Common/Convert.php';
//require_once 'Common/ajax.php';

//require_once 'wf/wfengine.php';
//require_once 'auth/models/QLVBDH_ACL.php';
//require_once 'fckeditor/fckeditor_php5.php' ;
//require_once 'qtht/models/qtht_year.php';

//if (!Zend_Session::isStarted()) {
//  Zend_Session::rememberMe();
//}

$auth = Zend_Auth::getInstance();
Zend_Registry::set('auth', $auth);

//$acl = new QLVBDH_ACL($auth);
//Zend_Registry::set('acl', $acl);

//$url = 'http://www.qlvbdh.vn/';
//Zend_Registry::set('url', $url);

//require_once 'auth/controllers/Auth_Plugin_Controller.php';
//$controller->registerPlugin(new Auth_Plugin_Controller($auth,$acl));

// should be turned true in development time, I had config error page , you must change before apply publish
require_once 'default/controllers/GenericController.php';
require_once 'default/controllers/ErrorController.php';
$controller->throwExceptions(false);  

try{
    $controller->dispatch();
}
catch (Exception  $ex){
	echo $ex->__toString();
}